package CartServiceBase

import (
	"context"
	"database/sql"
	toolsDb "gdshop-font-api-go/library/tools/db"
	"github.com/gogf/gf/frame/g"
	"time"
)

func Del(ctx context.Context, cartId int, memberId uint) (result sql.Result, err error) {
	return toolsDb.GetUnSafaTableAddDeleteWhere(ctx, "member_cart").Where(
		"member_id=? AND id=?",
		memberId,
		cartId,
	).Update(g.Map{
		"delete_at": int(time.Now().Unix()),
	})
}
func Dels(ctx context.Context, cartIds []int, memberId uint) (result sql.Result, err error) {
	if len(cartIds) < 1 {
		return nil, nil
	}
	return toolsDb.GetUnSafaTableAddDeleteWhere(ctx, "member_cart").Where(
		"member_id=? AND id IN (?)",
		memberId,
		cartIds,
	).Update(g.Map{
		"delete_at": int(time.Now().Unix()),
	})
}
